<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<html>
	<head>
		<base target="_self" />
		<meta http-equiv="pragma" content="no-cache">
        <meta http-equiv="cache-control" content="no-cache">
        <meta http-equiv="expires" content="0">
		<title>修改用户信息</title>
		<link rel="stylesheet" type="text/css" href="<c:url value="/static/jquery-easyui/themes/default/easyui.css"/>">
		<link rel="stylesheet" type="text/css"
			href="<c:url value="/static/jquery-easyui/themes/icon.css"/>">
		<script type="text/javascript"
			src="<c:url value="/static/jquery-easyui/jquery-1.6.min.js"/>"></script>
		<script type="text/javascript"
			src="<c:url value="/static/jquery-easyui/jquery.easyui.min.js"/>"></script>
		<script type="text/javascript"
			src="<c:url value="/static/jquery-easyui/plugins/jquery.panel.js"/>"></script>
		<script type="text/javascript"
			src="<c:url value="/static/jquery-easyui/plugins/jquery.datagrid.js"/>"></script>
		<script type="text/javascript"
			src="<c:url value="/static/jquery-easyui/plugins/jquery.messager.js"/>"></script>
		<script type="text/javascript"
			src="<c:url value="/static/jquery-easyui/ext-for-framework.js.jsp"/>"></script>
		<script type="text/javascript" src="<c:url value="/static/jquery-easyui/locale/easyui-lang-zh_CN.js"/>"></script>		

<%
	/* String userId = new String(request.getParameter("userId").getBytes("ISO-8859-1"),"gb2312");
	String userName = new String(request.getParameter("userName").getBytes("ISO-8859-1"),"gb2312");
	String realName = new String(request.getParameter("realName").getBytes("ISO-8859-1"),"gb2312");
	String organId = new String(request.getParameter("organId").getBytes("ISO-8859-1"),"gb2312");
	String email = new String(request.getParameter("email").getBytes("ISO-8859-1"),"gb2312");
	String isActive = new String(request.getParameter("isActive").getBytes("ISO-8859-1"),"gb2312"); */
%>

    <script type="text/javascript">
        $(document).ready(function() {
			$("#isActive").combobox('setValue',"${user.isActive }");
	    });
    	//修改信息按钮响应函数
		function updateUser(){
			
			$('#UpdateUserForm').form('submit',
			{
				url:'<c:url value='/user/updateUser.do'/>', //查询提交路径
				onSubmit:function()//提交按钮相应函数
				{
					return $('#UpdateUserForm').form('validate');
				},
				success:function(data){
					if(typeof(JSON)=='false'){
						data = eval('(' + data + ')');
					}else{
               			data = JSON.parse(data);
            		}
            		
	       			if(data.success){
	       				$.messager.alert("提示", "修改成功！", 'info');
	       				window.close();
       				}else{
	       				$.messager.alert("提示", data.msg, 'warning');
       				}
				},
				error:function(){
					$.messager.alert("错误", "系统错误，请联系管理员！", 'error');
					return;
				}
			});
 			
		}
    </script>
    <!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
  </head>

  <body>
    <table width="90%" align="center">
	  <tr></tr>
	  <tr>
		<td>
		
		  <div style="height: auto; background: #fafafa; padding: 5px;" class="easyui-panel" title="修改 用户信息" iconCls="icon-edit" 
		  collapsible="true" minimizable="false" maximizable="false" closable="false">
			
			<form id="UpdateUserForm" name="UpdateUserForm" method="post">
			  
			  <table cellpadding="5">
			      <tr>
			       <td>用户ID:</td>
                  <td>
				  <input class="easyui-validatebox" type="text" name="userId" value="${user.userId }" readonly/>
 			      </td>
                  <td>用户名:</td>
                  <td>
				  <input class="easyui-validatebox" type="text" name="userName" required="true" validType="length[1,30]" value="${user.userName }"/>
 			      </td>
  			      </tr>
 			      
 			      <tr>
 			      <td>密码:</td>
                  <td>
				  <input class="easyui-validatebox" type="password" required="true" validType="length[1,100]" name="password" value="${user.password }"/>
 			      </td>
                  <td>确认密码:</td>
                  <td>
				  <input class="easyui-validatebox" type="password" required="true" validType="length[1,100]" name="password2" value="${user.password }"/>
 			      </td>
  			      </tr>
  			    
  			      <tr>
  			      <td>姓名:</td>
                  <td>
				  <input class="easyui-validatebox" type="text" name="realName" required="true" validType="length[1,100]" value="${user.realName }"/>
 			      </td>
                  <td>机构编码:</td>
                  <td>
				  <input class="easyui-validatebox" type="text" name="organId" value="${user.organId }"/>
 			      </td>
                   
 			      </tr>
 			      
 			      <tr>
 			       <td>邮箱:</td>
                   <td>
				  <input class="easyui-validatebox" type="email" name="email" validType="email" validType="length[1,100]" value="${user.email }"/>
 			      </td>
                  <td>是否有效:</td>
                  <td>
			       <select class="easyui-combobox" id="isActive" name="isActive" value="1">
                   <option value="0" >有效</option> 
                   <option value="1" selected>失效</option>
                   </select>
 			      </td>
 			      </tr>
  			   </table>
			      
			     <br><br>
			     -----------------------角色选择---------------------------- <br>
 				  	<c:forEach var="role" items="${rolelist}" varStatus="st">
 				  	     <c:choose>
 				  	         <c:when test="${role.checked }">
 				  	          <input class="easyui-validatebox" type="checkBox" name="roles" checked
                              value="${role.roleId }">${role.roleName }</input>
 				  	        </c:when>
 				  	         <c:otherwise>
 				  	              <input class="easyui-validatebox" type="checkBox" name="roles"
                                 value="${role.roleId }">${role.roleName }</input>
 				  	         </c:otherwise>
  				  	     </c:choose>
 				  	     
                         <c:if test="${st.count % 5 == 0}">
                              <br><br>
                           </c:if>
                    </c:forEach>  
   			     <br><br>
 			     <a class="easyui-linkbutton" onclick="updateUser()">修改</a>
   			</form>
		  
		  
		  </div>
		</td>
	  </tr>
	</table>
  </body>
</html>